/*************************************************************************
	> File Name: histroyrecord.c
	> Author: QiyangXia
	> Mail: 834061456@qq.com 
	> Created Time: 2022年01月24日 星期一 20时13分29秒
 ************************************************************************/
#include "histroyrecord.h"
extern int inputcnt;
extern char user_name[]; 
int histroy()
{
	int outfd=-1;
	int i=0;
	int cnt = 0;
	int ret=0;
	char *pst=NULL;
	char txtname[30]="xxxxx";
	sprintf(txtname,"%s.log",user_name);  
	outfd=open(txtname,O_RDONLY);
	if(outfd<0)
	{
		printf("rb-fopen failed\n");
		return 1;
	}
	cnt = lseek(outfd,0,SEEK_END)-lseek(outfd,0,SEEK_SET);
	lseek(outfd,0,SEEK_SET);
	
	pst=(char *)malloc(cnt*sizeof(char));
	if(NULL==pst)
	{
		printf("malloc failed\n");
		return 2;
	}
	memset(pst,0,cnt*sizeof(char));
	
	ret=read(outfd,pst,cnt);

	printf("%s\n",pst);



	close(outfd);
	outfd = -1;

	free(pst);
	pst = NULL;
	return 0;
}


